package com.nova.edc.service.system.impl;

import java.util.List;

import com.nova.edc.model.system.ModelConstant;
import org.springframework.beans.factory.annotation.Autowired;

import com.nova.edc.dao.system.DeviceTypeDao;
import com.nova.edc.model.system.DeviceType;
import com.nova.edc.service.system.DeviceTypeService;
import com.nova.frame.dao.criterion.Restrictions;

public class DeviceTypeServiceImpl implements DeviceTypeService {

    @Autowired
    private DeviceTypeDao deviceTypeDao;

    @Override
    public List<DeviceType> findAll() {
        return deviceTypeDao.findAll();
    }

    @Override
    public DeviceType getById(Integer id) {
        return deviceTypeDao.getById(id);
    }

    @Override
    public List<DeviceType> findByExample(DeviceType deviceType) {
        return deviceTypeDao.findByExample(deviceType);
    }

    @Override
    public DeviceType getByName(String name) {
        return deviceTypeDao.query()
                .add(Restrictions.eq("t_device_type.Name", name)).get();
    }

    @Override
    public DeviceType getByExample(DeviceType deviceType) {
        return deviceTypeDao.getByExample(deviceType);
    }

    @Override
    public List<DeviceType> findLightAir() {
        return deviceTypeDao.query().add(Restrictions.or(
                Restrictions.eq("t_device_type.Name", ModelConstant.DEVICE_LIGHTENERGY),
                Restrictions.eq("t_device_type.Name", ModelConstant.DEVICE_AIR)
        )).list();
    }
}
